package ao.study.raa.base.util;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * 环境语言工具类.
 */
public class LangUtil{

    public static final Logger log = LoggerFactory.getLogger(LangUtil.class);

    public static final String ZH_CN = "zh_CN";

    public static final String EN_US = "en_US";

    public static final String I18_LANG_KEY = "clientlanguage";

    private String lang;

    private static final ThreadLocal<LangUtil> context = new ThreadLocal<LangUtil>(){

        @Override
        protected LangUtil initialValue(){
            return new LangUtil();
        }
    };

    public static LangUtil getCurrentContext(){
        return context.get();

    }

    /**
     * 获取当前线程设置的语言
     * 
     * @return
     */
    public static String getCurrentLang(){
        return getCurrentContext().lang;
    }

    /**
     * 设置当前线程的语言
     * 
     * @param lang
     */
    public static void setCurrentLang(String lang){
        getCurrentContext().lang = lang;
    }

    public static void remove(){
        context.remove();
    }

}
